import 'package:flutter/material.dart';

class ColorUtils {
  // 主色
  static const String primary = '#4053C0';
  static const Color primaryColor = Color(0xFF4053C0);
  static const Color primaryAlphaColor = Color(0x194053C0);
  static const Color primaryAlphaColor9 = Color(0x904053C0);
  static const Color primaryAlphaColor3 = Color(0xFFEFF3FF);

  // 背景色
  static const String background = '#F4F6F8';
  static const Color backgroundColor = Color(0xFFF4F6F8);
  static const Color backgroundColor6 = Color(0xFFECEEF0);
  static const Color backgroundColorList = Color(0xFFF3F4F7);

  static const Color backgroundColorTag = Color(0xFFF2F3FB);

  //弹窗背景色
  static const Color dialogBackgroundColor = Color(0x66000000);

  // 分隔线颜色
  static const String line = '#E1E1E1';
  static const Color lineColor = Color(0xFFE1E1E1);

  static const Color textDarkColor = Color(0xD8000000);
  static const Color textNormalColor = Color(0xA5000000);
  static const Color textLightColor = Color(0x72000000);
  static const Color textHintColor = Color(0x3F000000);

  // 文字颜色
  static const String textColor = '#000000';
  static const Color textColors = Color(0xFF000000);
  static const String textColor3 = '#333333';
  static const Color textColors3 = Color(0xFF333333);
  static const String textColor6 = '#666666';
  static const Color textColors6 = Color(0xFF666666);
  static const String textColor9 = '#999999';
  static const Color textColors9 = Color(0xFF999999);

  // 黄色
  static const yellowColor = Color(0xFFFDB21C);
  static const yellowAlphaColor = Color(0x19FDB21C);

  // 红色
  static const redColor = Color(0xFFE3483A);
  static const redAlphaColor = Color(0x19E3483A);

  // 绿色
  static const greenColor = Color(0xFF00B063);
  static const greenAlphaColor = Color(0x1900B063);

  // 蓝色
  static const blueColor = Color(0xFF1A84FD);
  static const blueAlphaColor = Color(0x191A84FD);

  // 灰色
  static const grayColor = Color(0xFFF0F4F7);

  // 白色
  static const whiteColor = Color(0xFFFFFFFF);
  static const whiteColor1 = Color(0xFFE9ECF8);

  // 静态方法，接受十六进制颜色字符串和透明度值，并返回 Flutter 的 Color 对象
  static Color hexToColor(String hex, {double opacity = 1.0}) {
    hex = hex.replaceAll('#', ''); // 去掉前面的 #

    if (hex.length == 6) {
      hex = 'FF$hex'; // 如果没有透明度值，默认加上 FF（不透明）
    }

    int colorValue = int.parse(hex, radix: 16); // 转换为颜色值
    int alpha = (opacity * 255).toInt(); // 将透明度转换为 0-255 范围的整数
    colorValue = (colorValue & 0xFFFFFF) | (alpha << 24); // 结合透明度和颜色值

    return Color(colorValue); // 返回颜色对象
  }
}
